<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="format-detection" content="email=no"/>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" name="viewport">
    <title>管理页面</title>
    <script src="./socket.io-1.4.5.js"></script>
    <script type="text/javascript" src="jquery.2.1.1.min.js"></script>
</head>
<body>
    <h1>管理员管理页面</h1>
    房间名：<input id="roomname" type="text" value="room01">
    <input id="openroom" type="button" value="开通房间">
    <input id="closeroom" type="button" value="关闭房间">
    <div>当前房间：<p id="online">0</p>人</div>
    <div style="width: 500px;height: 500px;overflow: auto" id="messages" class="chatbox">

    </div>
    <script>
        var socket = io.connect('http://192.168.2.52:3000');
        $("#openroom").on("click",function(){
            var roomName = $("#roomname").val();
            console.log(roomName);
            socket.emit('in room',{'functype':'openroom','roomName':roomName,'userName':'admin'});
            socket.on('chat message',function(msgObj){
                $('#messages').append($("<div>").html("<p>"+msgObj.userName+"说："+msgObj.msg+"</p>"));
                messages.scrollTop = messages.scrollHeight;
            })
        });
        $("#closeroom").on("click",function(){
            var roomName = $("#roomname").val();
            console.log(roomName);
            socket.emit('in room',{'functype':'closeroom','roomName':roomName,'userName':'admin'});
        });
    </script>
</body>
</html>